package com.project.biz.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.biz.CmsOperationLogBiz;
import com.project.entity.CmsOperationLog;
import com.project.entity.CmsOperationLog;
import com.project.mapper.CmsOperationLogMapper;
import com.project.mapper.CmsOperationLogMapper;
import com.project.pojo.dto.OperationLogDTO;
import com.project.pojo.model.OperationLogModel;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Description: 系统操作日志业务层接口实现类
 * @Author: zhuchi
 * @CreateDate: 2020/6/30 20:44
 * @Version: 1.0
 */
@Service
public class CmsOperationLogImpl extends ServiceImpl<CmsOperationLogMapper, CmsOperationLog> implements CmsOperationLogBiz {

    /**
     * 分页查询系统操作日志
     * @param operationLogModel
     * @return
     */
    public IPage<OperationLogDTO> getOperationLog(OperationLogModel operationLogModel){
        Page<OperationLogDTO> page = new Page<>(operationLogModel.getPageNo(), operationLogModel.getPageSize());
        return this.baseMapper.getOperationLog(page);
    }

    /**
     * 添加系统日志
     * @param userId
     * @param content
     * @return
     */
    public int addOperationLog(Long userId, String content){
        CmsOperationLog operationLog = new CmsOperationLog();
        operationLog.setCreateUser(userId);
        operationLog.setContent(content);
        operationLog.setCreateTime(new Date());
        return this.baseMapper.insert(operationLog);
    }

}
